Skip to content

perf: ZTS: use nl_langinfo for the decimal point instead of mutex-protected localeconv#22728

Open
henderkes wants to merge 1 commit into
php:masterfrom
henderkes:perf/localeconv
Open

perf: ZTS: use nl_langinfo for the decimal point instead of mutex-protected localeconv#22728
henderkes wants to merge 1 commit into
php:masterfrom
henderkes:perf/localeconv

Conversation

@henderkes

@henderkes henderkes commented Jul 14, 2026

Copy link
Copy Markdown
Contributor
workload master branch delta
sprintf("%.3f") 0.3456s 0.3034s −12.2%
number_format() 0.1560s 0.1401s −10.2%

benchmark script:

<?php
$s = microtime(true);
for ($i = 0; $i < 3000000; $i++) {
    $x = sprintf("%.3f", $i * 1.007);
}
$t1 = microtime(true) - $s;

$s = microtime(true);
for ($i = 0; $i < 1000000; $i++) {
    $x = number_format($i * 3.14159, 2);
}
$t2 = microtime(true) - $s;

printf("sprintf=%.4fs number_format=%.4fs\n", $t1, $t2);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant